﻿namespace Sidvall.Globalization
{
    public class CultureManager
    {
        #region Public Members

        public Sidvall.Globalization.ICultureProvider CultureProvider { get; set; }

        #region EnsureCorrectCurrentUICulture

        public void EnsureCorrectCurrentUICulture()
        {
            this.CultureProvider.EnsureCorrectCurrentUICulture();
        }

        #endregion
        #region GetCurrentUICulture

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
        public System.Globalization.CultureInfo GetCurrentUICulture()
        {
            EnsureCorrectCurrentUICulture();
            return System.Globalization.CultureInfo.CurrentUICulture;
        }

        #endregion
        #region SetCurrentCulture

        public void SetCurrentCulture(string name)
        {
            var cultureInfo = new System.Globalization.CultureInfo(name);
            SetCurrentCulture(cultureInfo);
        }
        public void SetCurrentCulture(System.Globalization.CultureInfo cultureInfo)
        {
            this.CultureProvider.SetCurrentCulture(cultureInfo);
        }

        #endregion
        #region SetCurrentUICulture

        public void SetCurrentUICulture(string name)
        {
            var cultureInfo = new System.Globalization.CultureInfo(name);
            SetCurrentUICulture(cultureInfo);
        }
        public void SetCurrentUICulture(System.Globalization.CultureInfo cultureInfo)
        {
            this.CultureProvider.SetCurrentUICulture(cultureInfo);
        }

        #endregion

        #region ToString

        public override string ToString()
        {
            return "CultureManager - Sidvall.Globalization.ICultureProvider";
        }

        #endregion

        #endregion
        #region Constructors

        public CultureManager(Sidvall.Globalization.ICultureProvider cultureProvider)
        {
            this.CultureProvider = cultureProvider;
        }

        #endregion
    }
}
